import 'package:date_format/date_format.dart';

class DateUtil {
  static ddmmyyyyFormat(String dateString) {
    var date = DateTime.parse(dateString);
    return formatDate(date, ['dd', '/', 'mm', '/', 'yyyy']);
  }

  static yyyymmFormat(String dateString) {
    var date = DateTime.parse(dateString);
    return formatDate(date, ['yyyy', '/', 'mm']);
  }

  static expFormat(String dateString) {
    return dateString.substring(0, 3) +
        dateString.substring(dateString.length - 2, dateString.length);
  }

  static DateTime ddmmyyyyParse(String str) {
    List<String> list = str.split(' ');
    String ddmmyyyy = list[0];
    
    List<String> dmyList = ddmmyyyy.split('/');
    String dd = dmyList[0];
    String mm = dmyList[1];
    String yyyy = dmyList[2];
    return DateTime.parse(yyyy + mm + dd);
  }
}
